/*
 * *******************************************************************
 *   @项目名称: BHex Android
 *   @文件名称: OtcApi.java
 *   @Date: 19-1-14 上午10:49
 *   @Author: ppzhao
 *   @Description:
 *   @Copyright（C）: 2019 BlueHelix Inc.   All rights reserved.
 *   注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的.
 *  *******************************************************************
 */

package io.bhex.sdk.otc;

import io.bhex.baselib.network.BParamsBuilder;
import io.bhex.baselib.network.HttpUtils;
import io.bhex.baselib.network.listener.SimpleResponseListener;
import io.bhex.baselib.network.params.PostParams;
import io.bhex.baselib.network.response.BaseResponse;
import io.bhex.sdk.OTCUrls;
import io.bhex.sdk.otc.bean.OtcConfigResponse;
import io.bhex.sdk.otc.bean.OtcItemResponse;
import io.bhex.sdk.otc.bean.OtcItemSimpleResponse;
import io.bhex.sdk.otc.bean.OtcLastPriceRequestBean;
import io.bhex.sdk.otc.bean.OtcLastPriceResponse;
import io.bhex.sdk.otc.bean.OtcListRequestBean;
import io.bhex.sdk.otc.bean.OtcListResponse;

public class OtcApi {
    /**
     * 获取Otc配置
     * @param listener
     */
    public static void getConfig(SimpleResponseListener<OtcConfigResponse> listener){
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_CONFIG)
                .build();
        HttpUtils.getInstance().request(params,OtcConfigResponse.class,listener);
    }

    /**
     * 获取最新价
     * @param requestBean
     * @param listener
     */
    public static void getLastPrice(OtcLastPriceRequestBean requestBean, SimpleResponseListener<OtcLastPriceResponse> listener){
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_INDEX)
//                .addParam("exchange_id",requestBean.exchange_id)
                .addParam("tokenId",requestBean.token_id)
                .addParam("currencyId",requestBean.currency_id)
                .addParam("side",requestBean.side)
                .build();
        HttpUtils.getInstance().request(params,OtcLastPriceResponse.class,listener);
    }


    /**
     * 获取广告列表
     * @param requestBean
     * @param listener
     */
    public static void getOtcList(OtcListRequestBean requestBean,SimpleResponseListener<OtcListResponse> listener){
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_LIST)
//                .addParam("exchange_id",requestBean.exchange_id)
                .addParam("tokenId",requestBean.token_id)
                .addParam("payment",requestBean.payment)
                .addParam("currencyId",requestBean.currency_id)
                .addParam("side",requestBean.side)
                .addParam("page",requestBean.page)
                .addParam("size",requestBean.size)
                .build();
        HttpUtils.getInstance().request(params,OtcListResponse.class,listener);
    }

    /**
     * 获取广告详情
     * @param itemId
     * @param listener
     */
    public static void getOtcDetail(String itemId, SimpleResponseListener<OtcItemResponse> listener){
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_DETAIL)
                .addParam("item_id",itemId)
                .build();
        HttpUtils.getInstance().request(params,OtcItemResponse.class,listener);
    }

    /**
     * 获取广告详情-简版
     * @param itemId
     * @param listener
     */
    public static void getOtcDetailSimple(String itemId, SimpleResponseListener<OtcItemSimpleResponse> listener){
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_DETAIL_SIMPLE)
                .addParam("item_id",itemId)
                .build();
        HttpUtils.getInstance().request(params,OtcItemSimpleResponse.class,listener);
    }
}
